<template>
  <a-card :bordered="false">
    <a-form
      ref="form"
      :model="form"
      :label-col="{ md: { span: 0 }, sm: { span: 24 } }"
      :wrapper-col="{ md: { span: 24 }, sm: { span: 24 } }"
    >
      <a-form-item label="">
        <tinymce v-model="form.content" :init="{height:800}"></tinymce>
      </a-form-item>
    </a-form>
    <!-- 底部工具栏 -->
    <div class="ele-bottom-tool">
      <div class="ele-bottom-tool-actions">
        <a-button v-if="user.roleId !== '2'"
                  type='primary' @click='updateProtocol'>确定</a-button>
      </div>
    </div>
  </a-card>

</template>

<script>
import { ProtocolApi } from '@/api/ProtocolApi';
import Tinymce from '@/components/TinymceEditor/index.vue';
import { DashboardApi } from '@/api/DashboardApi';

export default {
  name: 'protocol',
  components: { Tinymce },

  data() {
    return {
      // 用户信息
      user: {},

      form: {
        content: ''
      }
    };
  },
  mounted() {
    this.getUser();
  },

  // 初始化方法to
  async created() {
    const res = await ProtocolApi.findDetail({});
    this.form.content = res.data;
  },

  methods: {

    // 获取用户信息
    async getUser() {
      const res = await DashboardApi.getUser();
      this.user = res.data;
    },


    /**
     * 保存
     */
    async updateProtocol() {
      let result = null;
      result = ProtocolApi.edit(this.form);
      result
        .then(result => {
          // 提示添加成功
          this.$message.success(result.message);

        })
        .catch(() => {
          this.loading = false;
        });
    }
  }
};
</script>

<style scoped>
/*禁用调整大小*/
/deep/.tox-statusbar__resize-handle {
  visibility: hidden;
}
</style>
